using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Appointment : MonoBehaviour
{

    string[,] conversation = {
        {"恭迎主上","看主上似是有烦忧之事","眉头都皱起来了","在臣妾这里就不要想那些不开心的事啦，主上不开心，臣妾也会难过的","为了让主上开心，臣妾讲个笑话吧。","从前有个大老虎，碰上一只小白兔，啊呜，大老虎吃掉了小白兔。" },
        {"臣妾最喜欢一首诗了","坐酌泠泠水，看煎瑟瑟尘。","无由持一碗，寄与爱茶人。","主上与臣妾一样都是爱茶之人。","听说主上那里有来自江南的新茶，主上下次来给我带点呗","我们再一起看茶烟袅袅，听落棋声声。" },
        {"弱水三千只取一瓢饮，娇梅万朵独摘一枝怜。","臣妾想做主上那唯一的一瓢水、一枝梅。","青丝变白发","朝阳又夕下","三餐四季","煮茶赏花" },
        {"咳咳咳，臣妾是不......时日无多了......","大夫说，只有天山雪莲才能医治臣妾的病，可是天山雪莲是何等珍贵之物，到哪去弄来，臣妾怕是只能等死了吧......","(面色憔悴)......","药好苦，但是有主上陪着，心里很甜。","主上会经常来看臣妾的吗？","在生病的这些日子，有主上陪着我臣妾，臣妾真的好幸福。" },
        {"想为主上做一幅画","以心为笔","以情为墨","以爱你为内容","以余生为落笔","余生可待。" },
        {"有一种安排叫做缘，","冥冥之中，自有天意。","有一张网叫做情，","情网恢恢，疏而不漏。","有一种爱叫思念，","四处弥漫，牵牵绊绊。" }
    };
    //string a = VariableDocument.GetInstance.allHandsomeMen.getvalue(1,1);
    //随机数，选男宠
    int number;
    //随机数，选对话组合
    int order;
    //随机数，属性1
    int attribute1Is;
    //随机数，属性2
    int attribute2Is;
    //随机数，属性值1
    int attribute1VIs;
    //随机数，属性2
    int attribute2VIs;

    //男宠图控件
    public GameObject manImage;
    //男宠姓名控件
    public GameObject manName;
    //对话控件
    public GameObject words;
    //panel控件
    public GameObject panel;
    //属性1控件
    public GameObject attribute1;
    //属性1值控件
    public GameObject attribute1_value;
    //属性2控件
    public GameObject attribute2;
    //属性2值控件
    public GameObject attribute2_value;
    //确定按钮控件
    public GameObject okbtn;

    int a = 0;

    void Start()
    {
        number = Random.Range(0, 6);
        order = Random.Range(0, 6);
        attribute1Is = Random.Range(0, 4);
        attribute2Is = Random.Range(0, 4);
        attribute1VIs = Random.Range(10, 50);
        attribute2VIs = Random.Range(10, 50);

        manImage.GetComponent<Image>().sprite = Resources.Load<Sprite>(VariableDocument.GetInstance.allHandsomeMen[number, 1]);
        manName.GetComponent<Text>().text = VariableDocument.GetInstance.allHandsomeMen[number, 0];
        words.GetComponent<Text>().text = conversation[order, 0];
        attribute1.GetComponent<Text>().text = VariableDocument.GetInstance.attribute[attribute1Is];
        attribute2.GetComponent<Text>().text = VariableDocument.GetInstance.attribute[attribute2Is];
        //attribute1_value.GetComponent<Text>().text = "+" + attribute1VIs.ToString();
        //attribute2_value.GetComponent<Text>().text = "+" + attribute2VIs.ToString();

        //VariableDocument.GetInstance.attribute_value[attribute1Is] += attribute1VIs;
        //VariableDocument.GetInstance.attribute_value[attribute2Is] += attribute2VIs;

        //attribute1_value
        //attribute2
        //attribute2_value
    }
    int i = 1;
    // Update is called once per frame
    void Update()
    {
        if(Input.mousePosition.y < 660)
        {
            if (i < 6)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    words.GetComponent<Text>().text = conversation[order, i];
                    i++;
                }

            }
            else
            {
                if (Input.GetMouseButtonDown(0))
                {
                    if(a == 0)
                    {
                        attribute1_value.GetComponent<Text>().text = "+" + attribute1VIs.ToString();
                        attribute2_value.GetComponent<Text>().text = "+" + attribute2VIs.ToString();
                        VariableDocument.GetInstance.attribute_value[attribute1Is] += attribute1VIs;
                        VariableDocument.GetInstance.attribute_value[attribute2Is] += attribute2VIs;
                        a = 1;
                    }
                    panel.SetActive(true);
                    
                }

            }
        }
    }
}
